import { MigrationInterface, QueryRunner } from "typeorm";

export class Init1740964962193 implements MigrationInterface {
    name = 'Init1740964962193'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "task_comment_replies" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "content" text NOT NULL, "comment_id" uuid NOT NULL, "user_id" uuid NOT NULL, CONSTRAINT "PK_b416707b011a4c5abe9e36672a6" PRIMARY KEY ("id"))`);
        await queryRunner.query(`ALTER TABLE "task_comment_replies" ADD CONSTRAINT "FK_d62f8c91cc5c11058b81b5b18d6" FOREIGN KEY ("comment_id") REFERENCES "task_comments"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "task_comment_replies" ADD CONSTRAINT "FK_0009c546e3b7a999e560ef59355" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE "task_comment_replies" DROP CONSTRAINT "FK_0009c546e3b7a999e560ef59355"`);
        await queryRunner.query(`ALTER TABLE "task_comment_replies" DROP CONSTRAINT "FK_d62f8c91cc5c11058b81b5b18d6"`);
        await queryRunner.query(`DROP TABLE "task_comment_replies"`);
    }

}
